package nekperu15739.me.persistence.dao.implementations.jdbctemplate.h2;

import nekperu15739.me.persistence.dao.abstracts.jdbctemplate.LanguajeDaoAbstractJdbcTemplate;
import nekperu15739.me.persistence.dto.LanguageDto;
import nekperu15739.me.persistence.entities.LanguageEntity;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.RowMapper;
import org.springframework.stereotype.Repository;

@Repository
public class LanguajeDaoJdbcTemplateH2 extends LanguajeDaoAbstractJdbcTemplate {
    
    @Value("${web.language.selectById}")
    private String queryLanguajeById;
    
    @Autowired
    @Qualifier("languageDtoRowMapper")
    protected RowMapper<LanguageDto> languageEntityRowMapper;
    
    public LanguageDto select3(LanguageDto languageDto) {
        Object[] args = new Object[]{ languageDto.getLanguage() };
        
        JdbcTemplate template = getJdbcTemplate();
        LanguageDto dto = template.queryForObject(queryLanguajeById, args, languageEntityRowMapper);
        
//        getJdbcTemplate().queryForObject(sql, args, rowMapper);
//        return select(queryLanguajeById, args, languageEntityRowMapper);
        return dto;
    }
    
    public LanguageDto select(LanguageDto languageDto) {
        Object[] args = new Object[]{ languageDto.getLanguage() };
        return select(queryLanguajeById, args, languageEntityRowMapper);
//        return null;
    }

    @Autowired
    @Override
    protected void setJdbcTemplate(JdbcTemplate jdbcTemplate) {
        this.jdbcTemplate = jdbcTemplate;
    }



    @Override
    protected RowMapper<LanguageEntity> getEntityRowMapper() {
        // TODO Auto-generated method stub
        return null;
    }

    
}
